import { http } from '@/utils/http'
import { NewsItem } from '@/service/news/news'

export interface ProductItem {
  productId: number
  businessType: string
  productCode: string
  productPhoto: string
  origin: string
  longst: string
  wide: string
  height: string
  deep: string
  pressure: string
  netWeight: string
  grossWeight: string
  volume: string
  voltage: string
  power: string
  impeller: string
  pumpHouse: string
  insulationClass: string
  ipClass: string
  shaftSeal: string
  approvals: string
  maxHead: number
  maxFlow: number
  nominalHead: number
  nominalFlow: number
  maxHeadStr: string
  maxFlowStr: string
  nominalHeadStr: string
  nominalFlowStr: string
  minLiquidTemp: string
  maxLiquidTemp: string
  minAmbientTemp: string
  maxAmbientTemp: string
  pipeConnectionInletSize: string
  pipeConnectionOutletSize: string
  io: string
  quickGuide: string
  dataBooklet: string
  dimension: string
  performance: string
  materialGroup: string
  medium: string
  normsModel: string
  series: string
  connectionMethod: string
  productDesc2: string
  productDesc: string
  updateTime: string
  createTime: string
  rowId: number
  dbvalue: {
    keys: any[]
    values: any[]
    count: number
  }
  isDeletedInDatabase: boolean
  entityId: number
  isEnableCache: boolean
}

export interface ProductData {
  totalCount: number
  items: ProductItem[]
}

export interface ProductSearchParams {
  code?: string
  codedesc?: string
  desc?: string
  origin?: string
  start_maxHead?: number
  end_maxHead?: number
  start_maxFlow?: number
  end_maxFlow?: number
  isDBS?: boolean
  pageIndex?: number
  pageSize?: number
}

/** 产品列表搜索 */
export const searchProductList = ({
  code = '',
  codedesc = '',
  desc = '',
  origin = '',
  // eslint-disable-next-line camelcase
  start_maxHead = 0,
  // eslint-disable-next-line camelcase
  end_maxHead = 0,
  // eslint-disable-next-line camelcase
  start_maxFlow = 0,
  // eslint-disable-next-line camelcase
  end_maxFlow = 0,
  isDBS = true,
  pageIndex = 1,
  pageSize = 10,
}: ProductSearchParams = {}): Promise<IResData<ProductData>> => {
  return http.get<ProductData>('/api/MP/SearchProductList', {
    code,
    codedesc,
    desc,
    origin,
    // eslint-disable-next-line camelcase
    start_maxHead,
    // eslint-disable-next-line camelcase
    end_maxHead,
    // eslint-disable-next-line camelcase
    start_maxFlow,
    // eslint-disable-next-line camelcase
    end_maxFlow,
    isDBS,
    pageIndex,
    pageSize,
  })
}

/*
 * { "code": 200, "data":
 * { "approvals": "CE,RCM,VDE,LGABG,EAC,MORO, ", "businessType": "DBS", "connectionMethod": "",
 *  "createTime": "2023-10-18T15:28:36", "dataBooklet": "",
 *  "deep": "",
 *  "dimension": "/UploadFile/Data Package/Drawings/Dimensional Drawings/dd-99972805.png",
 *  "grossWeight": "13.053 KG", "height": "",
 *  "impeller": "不锈钢", "insulationClass": "F ",
 *  "io": "/UploadFile/Data Package/Documents/IO/96004693.pdf",
 *  "ipClass": "IP68 ", "longst": "", "materialGroup": "AP50B",
 * "maxAmbientTemp": "40 ℃", "maxFlow": 28, "maxFlowStr": "28 m3/h",
 *  "maxHead": 14, "maxHeadStr": "14.0 m", "maxLiquidTemp": "40 ℃",
 *  "medium": "", "minAmbientTemp": "0 ℃", "minLiquidTemp": "0℃",
 * "netWeight": "11.713 KG", "nominalFlow": 15.03, "nominalFlowStr": "15.03 m3/h",
 *  "nominalHead": 8, "nominalHeadStr": "8.0 m", "normsModel": "", "origin": "匈牙利",
 *  "performance": "", "pipeConnectionInletSize": "2", "pipeConnectionOutletSize": "2",
 *  "power": "1750.0 W", "pressure": "", "productCode": "99972805",
 *  "productDesc": "UNILIFT AP50B.50.11.A1V 1x230V 10m", "productDesc2": "", "productId": 417,
 *  "productPhoto": "/UploadFile/Data Package/Product Photo/99972805.png", "pumpHouse": "不锈钢",
 *  "quickGuide": "", "series": "", "shaftSeal": "", "updateTime": "2024-07-16T16:38:07",
 *  "voltage": "230", "volume": "28.256CDM ", "wide": "",
 *  "ioName": "96004693.pdf",
 *  "dimensionName": "dd-99972805.png", "isDBS": 1 }
 * , "message": "Success", "serviceTime": "2025-04-22T20:44:35.9289184+08:00" } */
/** 产品详情接口返回类型 */
export interface ProductDetail {
  approvals: string
  businessType: string
  connectionMethod: string
  createTime: string
  dataBooklet: string
  deep: string
  dimension: string
  grossWeight: string
  height: string
  impeller: string
  insulationClass: string
  io: string
  ipClass: string
  longst: string
  materialGroup: string
  maxAmbientTemp: string
  maxFlow: number
  maxFlowStr: string
  maxHead: number
  maxHeadStr: string
  maxLiquidTemp: string
  medium: string
  minAmbientTemp: string
  minLiquidTemp: string
  netWeight: string
  nominalFlow: number
  nominalFlowStr: string
  nominalHead: number
  nominalHeadStr: string
  normsModel: string
  origin: string
  performance: string
  pipeConnectionInletSize: string
  pipeConnectionOutletSize: string
  power: string
  pressure: string
  productCode: string
  productDesc: string
  productDesc2: string
  productId: number
  productPhoto: string
  pumpHouse: string
  quickGuide: string
  series: string
  shaftSeal: string
  updateTime: string
  voltage: string
  volume: string
  wide: string
  ioName: string
  dimensionName: string
  isDBS: number
}
/*
*
* <table border="1" cellspacing="0" class="paramTb">
    <tr>
        <td>产品编码P/N</td>
        <td>@product.ProductCode</td>
    </tr>
    <tr>
        <td>原产地COO</td>
        <td>@product.Origin</td>
    </tr>
    <tr>
        <td>状态Status</td>
        <td>@product.Approvals</td>
    </tr>
    <tr>
        <td>净重Net Weight</td>
        <td>@product.NetWeight</td>
    </tr>
    <tr>
        <td>毛重Gross Weight</td>
        <td>@product.GrossWeight</td>
    </tr>
    <tr>
        <td>体积Volume</td>
        <td>@product.Volume</td>
    </tr>
    <tr>
        <td>产品描述</td>
        <td>
            <span>@product.ProductDesc</span>
        </td>
    </tr>
    <tr>
        <td>电压Voltage</td>
        <td>@product.Voltage</td>
    </tr>
    <tr>
        <td>功率P1</td>
        <td>@product.Power</td>
    </tr>
    <tr>
        <td>最大扬程Max Head</td>
        <td>@product.MaxHeadStr</td>
    </tr>
    <tr>
        <td>
            最大流量Max Flow
        </td>
        <td>@product.MaxFlowStr</td>
    </tr>
    <tr>
        <td>
            额定扬程Nominal Head
        </td>
        <td>@product.NominalHeadStr</td>
    </tr>
    <tr>
        <td>
            额定流量Nominal Flow
        </td>
        <td>@product.NominalFlowStr</td>
    </tr>
    <tr>
        <td>
            最低液体温度Min liquid temp
        </td>
        <td>@product.MinLiquidTemp</td>
    </tr>
    <tr>
        <td>
            最高液体温度Max liquid temp
        </td>
        <td>@product.MaxLiquidTemp</td>
    </tr>
    <tr>
        <td>
            最低环境温度Min ambient temp
        </td>
        <td>@product.MinAmbientTemp</td>
    </tr>
    <tr>
        <td>
            最高环境温度Max ambient temp
        </td>
        <td>@product.MaxAmbientTemp</td>
    </tr>
    <tr>
        <td>
            产品编码
        </td>
        <td>@product.ProductCode</td>
    </tr>
    <tr>
        <td>
            吸水口尺寸
        </td>
        <td>@product.PipeConnectionInletSize</td>
    </tr>
    <tr>
        <td>
            出水口尺寸
        </td>
        <td>@product.PipeConnectionOutletSize</td>
    </tr> */

/** 获取产品详情 */
export const getProductDetail = (
  id: number,
  isDBS: number = 0,
): Promise<IResData<ProductDetail>> => {
  return http.get<ProductDetail>('/api/MP/ProductDetail', { id, isDBS })
}
